/*
 * @Author: 橘子
 * @Date: 2023-07-10 12:00
 * @Project_description: 查询树的操作
 * @Description: 代码是我抄的，不会也是真的
 */
'use strict'

/**
 * @Description: 深度优先遍历树
 * @author 橘子
 */
export const queryTreeBypath = (path, menuList) => {
  let menu = null
  for (let i = 0; i < menuList.length; i++) {
    const item = menuList[i]
    if (item.path === path) {
      menu = item
      break
    }
    if (item.children && item.children.length > 0) {
      menu = queryTreeBypath(path, item.children)
      if (menu) {
        break
      }
    }
  }
  return menu
}
